//
//  FootballTeamOrderTableViewCell.m
//  LiveSoftware
//
//  Created by lanou3g on 15/7/17.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "FootballTeamOrderTableViewCell.h"
#define kFootballTeamOrderFont 13

@implementation FootballTeamOrderTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.cellBackImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenIp6(50))];
        [self addSubview:_cellBackImageView];
        
        // 间隙
        CGFloat labelH = kScreenIp6(50);
        CGFloat labelW1  = kScreenIp6(40);
        CGFloat labelW2 = kScreenIp6(50);
        CGFloat logoW = kScreenIp6(30);
        CGFloat logoH = (kScreenIp6(50) - logoW) / 2;
        CGFloat labelW = (kScreenWidth - labelW1 - labelW2 - labelW1 - kScreenIp6(125) )/4;
        self.team_order = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, labelW1 ,labelH)];
        _team_order.textAlignment = NSTextAlignmentCenter;
        //        _team_order.backgroundColor = [UIColor redColor];
        _team_order.font = [UIFont systemFontOfSize:kFootballTeamOrderFont];
        [self.cellBackImageView addSubview:_team_order];
        
        
        self.logo = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_team_order.frame), logoH, logoW, logoW)];
        self.logo.image = [UIImage imageNamed:@"placeholder_pic_1"];
        [self.cellBackImageView addSubview:_logo];
        
        CGFloat team_cnW = kScreenIp6(90);
        self.team_cn = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_logo.frame) + kScreenIp6(5), 0, team_cnW,labelH )];
        //        _team_cn.backgroundColor = [UIColor redColor];
        self.team_cn.adjustsFontSizeToFitWidth = YES;
        _team_cn.font = [UIFont systemFontOfSize:kFootballTeamOrderFont];
        [self.cellBackImageView addSubview:_team_cn];
        
        
        self.count = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_team_cn.frame), 0, labelW,labelH )];
        _count.textAlignment = NSTextAlignmentCenter;
        //        _count.backgroundColor = [UIColor redColor];
        _count.font = [UIFont systemFontOfSize:kFootballTeamOrderFont];
        
        [self.cellBackImageView addSubview:_count];
        
        self.win = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_count.frame), 0, labelW ,labelH )];
        //        _win.backgroundColor = [UIColor redColor];
        self.win.textAlignment = NSTextAlignmentCenter;
        _win.font = [UIFont systemFontOfSize:kFootballTeamOrderFont];
        
        [self.cellBackImageView addSubview:_win];
        
        self.draw = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_win.frame), 0, labelW ,labelH )];
        //        _draw.backgroundColor = [UIColor redColor];
        
        _draw.font = [UIFont systemFontOfSize:kFootballTeamOrderFont];
        _draw.textAlignment = NSTextAlignmentCenter;
        
        [self.cellBackImageView addSubview:_draw];
        
        self.lose = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_draw.frame), 0, labelW ,labelH )];
        //        _lose.backgroundColor = [UIColor redColor];
        _lose.textAlignment = NSTextAlignmentCenter;
        _lose.font = [UIFont systemFontOfSize:kFootballTeamOrderFont];
        
        [self.cellBackImageView addSubview:_lose];
        
        self.goalAndLosegoal = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_lose.frame), 0, labelW2  ,labelH )];
        //        _goalAndLosegoal.backgroundColor = [UIColor redColor];
        _goalAndLosegoal.font = [UIFont systemFontOfSize:kFootballTeamOrderFont];
        _goalAndLosegoal.textAlignment = NSTextAlignmentCenter;
        
        [self.cellBackImageView addSubview:_goalAndLosegoal];
        
        self.score = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_goalAndLosegoal.frame), 0, labelW1 ,labelH )];
        //        _score.backgroundColor = [UIColor redColor];
        _score.textAlignment = NSTextAlignmentCenter;
        _score.font = [UIFont systemFontOfSize:kFootballTeamOrderFont];
        
        [self.cellBackImageView addSubview:_score];
        
        //线
        CGFloat partHeight = kScreenIp6(49);;
        UIView *footLineView = [[UIView  alloc]initWithFrame:CGRectMake( 0, partHeight, kScreenWidth, 0.5)];
        
        footLineView.backgroundColor = [UIColor colorWithWhite:0.699 alpha:1.000];
        // 设置 cell 点击没有变化
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self addSubview:footLineView];
        
    }
    
    return self;
    
}


- (void)setDataWithModel:(FootballTeamOrderModel *)model
{
    NSString *teamOrder = [NSString stringWithFormat:@"%@",model.team_order];
    self.team_order.text = teamOrder;
    self.team_cn.text = model.team_cn;
    [self.logo setImageWithURL:[NSURL URLWithString:model.logo]];
    self.count.text = model.count;
    self.win.text = model.win;
    self.draw.text = model.draw;
    self.lose.text = model.lose;
    NSString *goalAndLosegoal = [NSString stringWithFormat:@"%@/%@",model.goal,model.losegoal];
    self.goalAndLosegoal.text = goalAndLosegoal;
    self.score.text = model.score;
    
}

@end
